import { Component, OnInit ,DoCheck,Inject} from '@angular/core';
import {ChangeDetectionStrategy} from "@angular/core";
import {MAT_DIALOG_DATA,MatDialogRef} from "@angular/material"
import {User} from "../../domain/user.model";
@Component({
  selector: 'app-invite',
  templateUrl: './invite.component.html',
  styleUrls: ['./invite.component.scss'],
  changeDetection:ChangeDetectionStrategy.OnPush
})
export class InviteComponent implements OnInit,DoCheck {
  members :User[]=[];
  constructor(@Inject(MAT_DIALOG_DATA) private data,
              private dialogRef:MatDialogRef<InviteComponent>) { }

  ngOnInit() {
    this.members =[...this.data.members];
  }
  displayUser(user:{id:string,name:string}){
    return user?user.name:''
  }
  ngDoCheck(){
    console.log('projectinvite'+'本组件变更检测完毕')
  }
  onSubmit({valid,value},ev:Event){
    ev.preventDefault();
    if(!valid){
      return;
    }
    this.dialogRef.close(this.members);
  }
}
